<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>public/assets/css/h5/index.css">

<!-- 
<div class="contain">
    <p class="current">
    当前城市：<label><?php echo isset($area_info['title']) ? $area_info['title'] : ''?></label>&nbsp;&nbsp;<label><?php echo isset($city_info['title']) ? $city_info['title'] : ''?></label>
    <a href="<?php echo base_url()?>bind/area" class="change">切换</a>
    </p>
    
    <p class="current">就近园区：<label><?php echo isset($nursery_info['title']) ? $nursery_info['title'] : ''?></label>
    <a href="<?php echo base_url()?>bind/nursery?cid=<?php echo isset($city_info['id']) ? $city_info['id'] : ''?>&aid=<?php echo isset($area_info['id']) ? $area_info['id'] : ''?>&ct=<?php echo isset($city_info['title']) ? $city_info['title'] : ''?>&at=<?php echo isset($area_info['title']) ? $area_info['title'] : ''?>" class="change">切换</a>
    </p>
</div>
 -->

<div class="contain">
    <p class="current">
    &nbsp;<label><?php echo isset($area_info['title']) ? $area_info['title'] : ''?></label><label><?php echo isset($city_info['title']) ? $city_info['title'] : ''?></label>
    &nbsp;&nbsp;
    <label><?php echo isset($nursery_info['title']) ? $nursery_info['title'] : ''?></label>
    <a href="<?php echo base_url()?>bind/area" class="change">切换</a>
    </p>
</div>


<div class="contain" id="change">
    <div class="imgbox">
        <a href="#"><img src="<?php echo base_url()?>/public/assets/images/h5/banner.jpg"></a>
        <a href="#"><img src="<?php echo base_url()?>/public/assets/images/h5/banner.jpg"></a>
        <a href="#"><img src="<?php echo base_url()?>/public/assets/images/h5/banner.jpg"></a>
        <a href="#"><img src="<?php echo base_url()?>/public/assets/images/h5/banner.jpg"></a>
    </div>
</div>

<?php if(!$this->_is_teacher){?>
<?php if($this->_uid){?>
<div class="contain">
    <p><em class="icon"></em>我的课包<a href="<?php echo base_url()?>coursepackage/cplist">更多&nbsp;&nbsp;<i class="fa fa-angle-right"></i></p>
</div>
<?php if($cp_data){?>
    <?php foreach ($cp_data as $k=>$v){?>
<div class="contain">    
    <a href="javascript:void(0);" class="a_padding_bottom weui_media_box weui_media_appmsg">
        <div class="weui_media_bd" >
            <h4 class="weui_media_title">
                <?php echo $v['title'];?>
                <span class="<?php echo $v['surplus_hours']<=0 ? 'done' : '';?>">
                <?php if($v['status']==0){?>待支付
                <?php }elseif ($v['status']==2){?>已退款
                <?php }elseif ($v['status']==3){?>划课待审核
                <?php }elseif ($v['status']==4){?>划课审核失败
                <?php }elseif ($v['status']==6){?>已过期
                <?php }else{ echo $v['surplus_hours']<=0 ? '已用完' :'未用完'; }?>
                </span>
            </h4>
            <p style="padding-left: 0px;"class="weui_media_desc">共<em><?php echo $v['hours']?></em>课时，剩余<em><?php echo $v['surplus_hours'];?></em>课时</p>
        </div>
    </a>
    
    <div class="div">
    <a class="weui_btn weui_btn_mini weui_btn_default" href="<?php echo base_url()?>coursepackage/info?order_id=<?php echo $v['id']?>">查看详情</a>
    
    <?php if($v['status']==0){?>
    <a class="weui_btn weui_btn_mini weui_btn_default" href="<?php echo base_url()?>order/go_pay/?order_id=<?php echo id_encode($v['id'])?>">立即支付</a>
    <?php }elseif( ($v['status']==1 || $v['status']==5) && $v['surplus_hours'] > 0){?>
    <a class="weui_btn weui_btn_mini weui_btn_default" href="<?php echo base_url()?>purchasecourse/?order_id=<?php echo $v['id']?>">立即约课</a>
    <?php }?>
    </div>
    
</div>



<?php }?>
<?php }else{?>
<div class="contain" style="margin-top: -2%">
    <a href="javascript:void(0);" class="weui_media_box weui_media_appmsg" style="padding-left: 40%;">
        暂无课包信息
    </a>
</div>
<?php }?>
<?php }else{?>
<div class="contain">
    <div class="weui_media_box weui_media_appmsg" style="padding-left: 30%;">
        <label class="weui_media_desc">您还没有登录，</label>
        <a href="<?php echo base_url()?>login" class="weui_media_desc" style="color:#f96a92;">马上登录</a>
    </div>
     
</div>
<?php }?>
<?php }?>

<div class="contain">
    <p><em class="icon"></em>预约课程</p>
</div>
<div class="contain">
    <?php foreach ($cc_data as $k=>$v){?>
    <a href="<?php echo base_url()?>index/clist?ccid=<?php echo $v['id']?>" class="weui_media_box weui_media_appmsg" style="position: relative;" style="border-bottom: 1px solid #e5e5e5">
        <div class="weui_media_hd" >
            <img class="weui_media_appmsg_thumb" src="<?php echo base_url()?>public/assets/images/h5/class.jpg" alt="">
        </div>
        <div class="weui_media_bd" >
            <h4 class="weui_media_title"><?php echo $v['title']?><em><?php echo $v['cl_num']?>种课程可选</em></h4>
            <p class="weui_media_desc"><em><?php echo $v['sales']?></em>人已购买早教课</p>
            <span class="arrow"><i class="fa  fa-angle-right"></i></span>
        </div>
    </a>
    <?php }?>
</div>
        
        
<script type="text/javascript">
    $(document).ready(function(){

        var width = window.screen.width;
        var height = width*0.525;
        var n = $(".imgbox a").size();

        $("#change").height(height);
        $("#change").width(width);
        $(".imgbox").width(width*n);
        $(".imgbox").height(height);
        $(".imgbox img").width(width);

        var flag = 0;
        var timer;
        tt();
        function tt() {
            var _args = arguments;
            timer = setTimeout(function () {

                imgScroll(1);
                _args.callee();
            },5000);
        }


        function imgScroll(dir) {
            if(flag<n-1 && dir == 1){
                var left = parseInt($(".imgbox").css("left"));
                left = (left - width)+"px";
                $(".imgbox").animate({left:left},500);
                flag++;
            }
            else if (flag > 0 && dir == -1 ) {
                var left = parseInt($(".imgbox").css("left"));
                left = (left + width)+"px";
                $(".imgbox").animate({left:left},500);
                flag--;
            }
            else{
                $(".imgbox").animate({left:"0px"},500);
                flag=0;
            }
        }

        var preX;
        $(".imgbox").on("touchstart", function(e) {
            var currX = e.originalEvent.changedTouches[0].clientX;

            preX = currX;

        })

        $(".imgbox").on("touchend", function(e) {
            var currX = e.originalEvent.changedTouches[0].clientX;
            if (currX - preX > 0) {
                console.log("right");
                imgScroll(-1);
            }  else {
                console.log("left");
                imgScroll(1);
            }
            clearTimeout(timer);
            tt();
        })
    });

</script>
